package com.d09cnpm2.group8.dao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class TravelSQLiteHelper extends SQLiteOpenHelper {
    private static final String DBNAME = "travelDB";
    public static final String COL_ID = "id";
    public static final String COL_CITY = "city";
    public static final String COL_NAME = "name";
    public static final String COL_TYPE = "type";
    public static final String COL_DESC = "descript";
    public static final String COL_LONG = "longtitude";
    public static final String COL_LAT = "latitude";
    public static final String COL_IMG = "imgLink";
    public static String[] allColumns = {COL_ID, COL_NAME, COL_TYPE, COL_DESC, COL_LONG, COL_LAT,COL_CITY, COL_IMG};
    private static final int DB_VERSION = 6;
    public static final String TRAVEL_TBL = "travel";

    private final String DB_CREATE = "create table " + TRAVEL_TBL + "("
	    + COL_ID + " integer primary key autoincrement, " + COL_NAME
	    + " text, " + COL_TYPE + " text not null, " + COL_DESC + " text, "
	    + COL_LONG + " float, " + COL_LAT + " float, " + COL_CITY
	    + " text, " + COL_IMG + " text);";
    private String TAG = "--------SQLite helper------->";

    public TravelSQLiteHelper(Context context) {
	super(context, DBNAME, null, DB_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
	db.execSQL(DB_CREATE);
	Log.e(TAG , "database created");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int arg1, int arg2) {
	db.execSQL("drop table if exists " + TRAVEL_TBL);
	onCreate(db);
    }

}
